<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - poll/unix/select.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">poll/unix</a> - select.c<span style="font-size: 80%;"> (source / <a href="select.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">95</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">62</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #ifdef WIN32
<span class="lineNum">      18 </span>                :            : /* POSIX defines 1024 for the FD_SETSIZE */
<span class="lineNum">      19 </span>                :            : #define FD_SETSIZE 1024
<span class="lineNum">      20 </span>                :            : #endif
<span class="lineNum">      21 </span>                :            : 
<span class="lineNum">      22 </span>                :            : #include &quot;apr.h&quot;
<span class="lineNum">      23 </span>                :            : #include &quot;apr_poll.h&quot;
<span class="lineNum">      24 </span>                :            : #include &quot;apr_time.h&quot;
<span class="lineNum">      25 </span>                :            : #include &quot;apr_portable.h&quot;
<span class="lineNum">      26 </span>                :            : #include &quot;apr_arch_file_io.h&quot;
<span class="lineNum">      27 </span>                :            : #include &quot;apr_arch_networkio.h&quot;
<span class="lineNum">      28 </span>                :            : #include &quot;apr_arch_poll_private.h&quot;
<span class="lineNum">      29 </span>                :            : 
<span class="lineNum">      30 </span>                :            : #ifdef POLL_USES_SELECT
<span class="lineNum">      31 </span>                :            : 
<span class="lineNum">      32 </span>                :            : APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num,
<span class="lineNum">      33 </span>                :            :                                    apr_int32_t *nsds,
<span class="lineNum">      34 </span>                :            :                                    apr_interval_time_t timeout)
<span class="lineNum">      35 </span>                :            : {
<span class="lineNum">      36 </span>                :            :     fd_set readset, writeset, exceptset;
<span class="lineNum">      37 </span>                :            :     int rv, i;
<span class="lineNum">      38 </span>                :            :     int maxfd = -1;
<span class="lineNum">      39 </span>                :            :     struct timeval tv, *tvptr;
<span class="lineNum">      40 </span>                :            : #ifdef NETWARE
<span class="lineNum">      41 </span>                :            :     apr_datatype_e set_type = APR_NO_DESC;
<span class="lineNum">      42 </span>                :            : #endif
<span class="lineNum">      43 </span>                :            : 
<span class="lineNum">      44 </span>                :            :     if (timeout &lt; 0) {
<span class="lineNum">      45 </span>                :            :         tvptr = NULL;
<span class="lineNum">      46 </span>                :            :     }
<span class="lineNum">      47 </span>                :            :     else {
<span class="lineNum">      48 </span>                :            :         tv.tv_sec = (long) apr_time_sec(timeout);
<span class="lineNum">      49 </span>                :            :         tv.tv_usec = (long) apr_time_usec(timeout);
<span class="lineNum">      50 </span>                :            :         tvptr = &amp;tv;
<span class="lineNum">      51 </span>                :            :     }
<span class="lineNum">      52 </span>                :            : 
<span class="lineNum">      53 </span>                :            :     FD_ZERO(&amp;readset);
<span class="lineNum">      54 </span>                :            :     FD_ZERO(&amp;writeset);
<span class="lineNum">      55 </span>                :            :     FD_ZERO(&amp;exceptset);
<span class="lineNum">      56 </span>                :            : 
<span class="lineNum">      57 </span>                :            :     for (i = 0; i &lt; num; i++) {
<span class="lineNum">      58 </span>                :            :         apr_os_sock_t fd;
<span class="lineNum">      59 </span>                :            : 
<span class="lineNum">      60 </span>                :            :         aprset[i].rtnevents = 0;
<span class="lineNum">      61 </span>                :            : 
<span class="lineNum">      62 </span>                :            :         if (aprset[i].desc_type == APR_POLL_SOCKET) {
<span class="lineNum">      63 </span>                :            : #ifdef NETWARE
<span class="lineNum">      64 </span>                :            :             if (HAS_PIPES(set_type)) {
<span class="lineNum">      65 </span>                :            :                 return APR_EBADF;
<span class="lineNum">      66 </span>                :            :             }
<span class="lineNum">      67 </span>                :            :             else {
<span class="lineNum">      68 </span>                :            :                 set_type = APR_POLL_SOCKET;
<span class="lineNum">      69 </span>                :            :             }
<span class="lineNum">      70 </span>                :            : #endif
<span class="lineNum">      71 </span>                :            :             fd = aprset[i].desc.s-&gt;socketdes;
<span class="lineNum">      72 </span>                :            :         }
<span class="lineNum">      73 </span>                :            :         else if (aprset[i].desc_type == APR_POLL_FILE) {
<span class="lineNum">      74 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">      75 </span>                :            :             return APR_EBADF;
<span class="lineNum">      76 </span>                :            : #else
<span class="lineNum">      77 </span>                :            : #ifdef NETWARE
<span class="lineNum">      78 </span>                :            :             if (aprset[i].desc.f-&gt;is_pipe &amp;&amp; !HAS_SOCKETS(set_type)) {
<span class="lineNum">      79 </span>                :            :                 set_type = APR_POLL_FILE;
<span class="lineNum">      80 </span>                :            :             }
<span class="lineNum">      81 </span>                :            :             else
<span class="lineNum">      82 </span>                :            :                 return APR_EBADF;
<span class="lineNum">      83 </span>                :            : #endif /* NETWARE */
<span class="lineNum">      84 </span>                :            : 
<span class="lineNum">      85 </span>                :            :             fd = aprset[i].desc.f-&gt;filedes;
<span class="lineNum">      86 </span>                :            : 
<span class="lineNum">      87 </span>                :            : #endif /* APR_FILES_AS_SOCKETS */
<span class="lineNum">      88 </span>                :            :         }
<span class="lineNum">      89 </span>                :            :         else {
<span class="lineNum">      90 </span>                :            :             break;
<span class="lineNum">      91 </span>                :            :         }
<span class="lineNum">      92 </span>                :            : #if !defined(WIN32) &amp;&amp; !defined(NETWARE)        /* socket sets handled with array of handles */
<span class="lineNum">      93 </span>                :            :         if (fd &gt;= FD_SETSIZE) {
<span class="lineNum">      94 </span>                :            :             /* XXX invent new error code so application has a clue */
<span class="lineNum">      95 </span>                :            :             return APR_EBADF;
<span class="lineNum">      96 </span>                :            :         }
<span class="lineNum">      97 </span>                :            : #endif
<span class="lineNum">      98 </span>                :            :         if (aprset[i].reqevents &amp; APR_POLLIN) {
<span class="lineNum">      99 </span>                :            :             FD_SET(fd, &amp;readset);
<span class="lineNum">     100 </span>                :            :         }
<span class="lineNum">     101 </span>                :            :         if (aprset[i].reqevents &amp; APR_POLLOUT) {
<span class="lineNum">     102 </span>                :            :             FD_SET(fd, &amp;writeset);
<span class="lineNum">     103 </span>                :            :         }
<span class="lineNum">     104 </span>                :            :         if (aprset[i].reqevents &amp;
<span class="lineNum">     105 </span>                :            :             (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) {
<span class="lineNum">     106 </span>                :            :             FD_SET(fd, &amp;exceptset);
<span class="lineNum">     107 </span>                :            :         }
<span class="lineNum">     108 </span>                :            :         if ((int) fd &gt; maxfd) {
<span class="lineNum">     109 </span>                :            :             maxfd = (int) fd;
<span class="lineNum">     110 </span>                :            :         }
<span class="lineNum">     111 </span>                :            :     }
<span class="lineNum">     112 </span>                :            : 
<span class="lineNum">     113 </span>                :            : #ifdef NETWARE
<span class="lineNum">     114 </span>                :            :     if (HAS_PIPES(set_type)) {
<span class="lineNum">     115 </span>                :            :         rv = pipe_select(maxfd + 1, &amp;readset, &amp;writeset, &amp;exceptset, tvptr);
<span class="lineNum">     116 </span>                :            :     }
<span class="lineNum">     117 </span>                :            :     else {
<span class="lineNum">     118 </span>                :            : #endif
<span class="lineNum">     119 </span>                :            : 
<span class="lineNum">     120 </span>                :            :         rv = select(maxfd + 1, &amp;readset, &amp;writeset, &amp;exceptset, tvptr);
<span class="lineNum">     121 </span>                :            : 
<span class="lineNum">     122 </span>                :            : #ifdef NETWARE
<span class="lineNum">     123 </span>                :            :     }
<span class="lineNum">     124 </span>                :            : #endif
<span class="lineNum">     125 </span>                :            : 
<span class="lineNum">     126 </span>                :            :     (*nsds) = rv;
<span class="lineNum">     127 </span>                :            :     if ((*nsds) == 0) {
<span class="lineNum">     128 </span>                :            :         return APR_TIMEUP;
<span class="lineNum">     129 </span>                :            :     }
<span class="lineNum">     130 </span>                :            :     if ((*nsds) &lt; 0) {
<span class="lineNum">     131 </span>                :            :         return apr_get_netos_error();
<span class="lineNum">     132 </span>                :            :     }
<span class="lineNum">     133 </span>                :            : 
<span class="lineNum">     134 </span>                :            :     (*nsds) = 0;
<span class="lineNum">     135 </span>                :            :     for (i = 0; i &lt; num; i++) {
<span class="lineNum">     136 </span>                :            :         apr_os_sock_t fd;
<span class="lineNum">     137 </span>                :            : 
<span class="lineNum">     138 </span>                :            :         if (aprset[i].desc_type == APR_POLL_SOCKET) {
<span class="lineNum">     139 </span>                :            :             fd = aprset[i].desc.s-&gt;socketdes;
<span class="lineNum">     140 </span>                :            :         }
<span class="lineNum">     141 </span>                :            :         else if (aprset[i].desc_type == APR_POLL_FILE) {
<span class="lineNum">     142 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">     143 </span>                :            :             return APR_EBADF;
<span class="lineNum">     144 </span>                :            : #else
<span class="lineNum">     145 </span>                :            :             fd = aprset[i].desc.f-&gt;filedes;
<span class="lineNum">     146 </span>                :            : #endif
<span class="lineNum">     147 </span>                :            :         }
<span class="lineNum">     148 </span>                :            :         else {
<span class="lineNum">     149 </span>                :            :             break;
<span class="lineNum">     150 </span>                :            :         }
<span class="lineNum">     151 </span>                :            :         if (FD_ISSET(fd, &amp;readset)) {
<span class="lineNum">     152 </span>                :            :             aprset[i].rtnevents |= APR_POLLIN;
<span class="lineNum">     153 </span>                :            :         }
<span class="lineNum">     154 </span>                :            :         if (FD_ISSET(fd, &amp;writeset)) {
<span class="lineNum">     155 </span>                :            :             aprset[i].rtnevents |= APR_POLLOUT;
<span class="lineNum">     156 </span>                :            :         }
<span class="lineNum">     157 </span>                :            :         if (FD_ISSET(fd, &amp;exceptset)) {
<span class="lineNum">     158 </span>                :            :             aprset[i].rtnevents |= APR_POLLERR;
<span class="lineNum">     159 </span>                :            :         }
<span class="lineNum">     160 </span>                :            :         if (aprset[i].rtnevents) {
<span class="lineNum">     161 </span>                :            :             (*nsds)++;
<span class="lineNum">     162 </span>                :            :         }
<span class="lineNum">     163 </span>                :            :     }
<span class="lineNum">     164 </span>                :            : 
<span class="lineNum">     165 </span>                :            :     return APR_SUCCESS;
<span class="lineNum">     166 </span>                :            : }
<span class="lineNum">     167 </span>                :            : 
<span class="lineNum">     168 </span>                :            : #endif /* POLL_USES_SELECT */
<span class="lineNum">     169 </span>                :            : 
<span class="lineNum">     170 </span>                :            : struct apr_pollset_private_t
<span class="lineNum">     171 </span>                :            : {
<span class="lineNum">     172 </span>                :            :     fd_set readset, writeset, exceptset;
<span class="lineNum">     173 </span>                :            :     int maxfd;
<span class="lineNum">     174 </span>                :            :     apr_pollfd_t *query_set;
<span class="lineNum">     175 </span>                :            :     apr_pollfd_t *result_set;
<span class="lineNum">     176 </span>                :            :     apr_uint32_t flags;
<span class="lineNum">     177 </span>                :            : #ifdef NETWARE
<span class="lineNum">     178 </span>                :            :     int set_type;
<span class="lineNum">     179 </span>                :            : #endif
<span class="lineNum">     180 </span>                :            : };
<span class="lineNum">     181 </span>                :            : 
<span class="lineNum">     182 </span>                :            : static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
<span class="lineNum">     183 </span>                :            :                                         apr_uint32_t size,
<a name="184"><span class="lineNum">     184 </span>                :            :                                         apr_pool_t *p,</a>
<span class="lineNum">     185 </span>                :            :                                         apr_uint32_t flags)
<span class="lineNum">     186 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     187 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (flags &amp; APR_POLLSET_THREADSAFE) {                </span>
<span class="lineNum">     188 </span>                :<span class="lineNoCov">          0 :         pollset-&gt;p = NULL;</span>
<span class="lineNum">     189 </span>                :<span class="lineNoCov">          0 :         return APR_ENOTIMPL;</span>
<span class="lineNum">     190 </span>                :            :     }
<span class="lineNum">     191 </span>                :            : #ifdef FD_SETSIZE
<span class="lineNum">     192 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (size &gt; FD_SETSIZE) {</span>
<span class="lineNum">     193 </span>                :<span class="lineNoCov">          0 :         pollset-&gt;p = NULL;</span>
<span class="lineNum">     194 </span>                :<span class="lineNoCov">          0 :         return APR_EINVAL;</span>
<span class="lineNum">     195 </span>                :            :     }
<span class="lineNum">     196 </span>                :            : #endif
<span class="lineNum">     197 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;p = apr_palloc(p, sizeof(apr_pollset_private_t));</span>
<span class="lineNum">     198 </span>                :<span class="lineNoCov">          0 :     FD_ZERO(&amp;(pollset-&gt;p-&gt;readset));</span>
<span class="lineNum">     199 </span>                :<span class="lineNoCov">          0 :     FD_ZERO(&amp;(pollset-&gt;p-&gt;writeset));</span>
<span class="lineNum">     200 </span>                :<span class="lineNoCov">          0 :     FD_ZERO(&amp;(pollset-&gt;p-&gt;exceptset));</span>
<span class="lineNum">     201 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;p-&gt;maxfd = 0;</span>
<span class="lineNum">     202 </span>                :            : #ifdef NETWARE
<span class="lineNum">     203 </span>                :            :     pollset-&gt;p-&gt;set_type = APR_NO_DESC;
<span class="lineNum">     204 </span>                :            : #endif
<span class="lineNum">     205 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;p-&gt;query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));</span>
<span class="lineNum">     206 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;p-&gt;result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));</span>
<span class="lineNum">     207 </span>                :            : 
<span class="lineNum">     208 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">     209 </span>                :            : }
<span class="lineNum">     210 </span>                :            : 
<a name="211"><span class="lineNum">     211 </span>                :            : static apr_status_t impl_pollset_add(apr_pollset_t *pollset,</a>
<span class="lineNum">     212 </span>                :            :                                      const apr_pollfd_t *descriptor)
<span class="lineNum">     213 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     214 </span>                :            :     apr_os_sock_t fd;
<span class="lineNum">     215 </span>                :            : 
<span class="lineNum">     216 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (pollset-&gt;nelts == pollset-&gt;nalloc) {</span>
<span class="lineNum">     217 </span>                :<span class="lineNoCov">          0 :         return APR_ENOMEM;</span>
<span class="lineNum">     218 </span>                :            :     }
<span class="lineNum">     219 </span>                :            : 
<span class="lineNum">     220 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;p-&gt;query_set[pollset-&gt;nelts] = *descriptor;</span>
<span class="lineNum">     221 </span>                :            : 
<span class="lineNum">     222 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptor-&gt;desc_type == APR_POLL_SOCKET) {</span>
<span class="lineNum">     223 </span>                :            : #ifdef NETWARE
<span class="lineNum">     224 </span>                :            :         /* NetWare can't handle mixed descriptor types in select() */
<span class="lineNum">     225 </span>                :            :         if (HAS_PIPES(pollset-&gt;p-&gt;set_type)) {
<span class="lineNum">     226 </span>                :            :             return APR_EBADF;
<span class="lineNum">     227 </span>                :            :         }
<span class="lineNum">     228 </span>                :            :         else {
<span class="lineNum">     229 </span>                :            :             pollset-&gt;p-&gt;set_type = APR_POLL_SOCKET;
<span class="lineNum">     230 </span>                :            :         }
<span class="lineNum">     231 </span>                :            : #endif
<span class="lineNum">     232 </span>                :<span class="lineNoCov">          0 :         fd = descriptor-&gt;desc.s-&gt;socketdes;</span>
<span class="lineNum">     233 </span>                :            :     }
<span class="lineNum">     234 </span>                :            :     else {
<span class="lineNum">     235 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">     236 </span>                :            :         if ((pollset-&gt;flags &amp; APR_POLLSET_WAKEABLE) &amp;&amp;
<span class="lineNum">     237 </span>                :            :             descriptor-&gt;desc.f == pollset-&gt;wakeup_pipe[0])
<span class="lineNum">     238 </span>                :            :             fd = (apr_os_sock_t)descriptor-&gt;desc.f-&gt;filedes;
<span class="lineNum">     239 </span>                :            :         else
<span class="lineNum">     240 </span>                :            :             return APR_EBADF;
<span class="lineNum">     241 </span>                :            : #else
<span class="lineNum">     242 </span>                :            : #ifdef NETWARE
<span class="lineNum">     243 </span>                :            :         /* NetWare can't handle mixed descriptor types in select() */
<span class="lineNum">     244 </span>                :            :         if (descriptor-&gt;desc.f-&gt;is_pipe &amp;&amp; !HAS_SOCKETS(pollset-&gt;p-&gt;set_type)) {
<span class="lineNum">     245 </span>                :            :             pollset-&gt;p-&gt;set_type = APR_POLL_FILE;
<span class="lineNum">     246 </span>                :            :             fd = descriptor-&gt;desc.f-&gt;filedes;
<span class="lineNum">     247 </span>                :            :         }
<span class="lineNum">     248 </span>                :            :         else {
<span class="lineNum">     249 </span>                :            :             return APR_EBADF;
<span class="lineNum">     250 </span>                :            :         }
<span class="lineNum">     251 </span>                :            : #else
<span class="lineNum">     252 </span>                :<span class="lineNoCov">          0 :         fd = descriptor-&gt;desc.f-&gt;filedes;</span>
<span class="lineNum">     253 </span>                :            : #endif
<span class="lineNum">     254 </span>                :            : #endif
<span class="lineNum">     255 </span>                :            :     }
<span class="lineNum">     256 </span>                :            : #if !defined(WIN32) &amp;&amp; !defined(NETWARE)        /* socket sets handled with array of handles */
<span class="lineNum">     257 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (fd &gt;= FD_SETSIZE) {</span>
<span class="lineNum">     258 </span>                :            :         /* XXX invent new error code so application has a clue */
<span class="lineNum">     259 </span>                :<span class="lineNoCov">          0 :         return APR_EBADF;</span>
<span class="lineNum">     260 </span>                :            :     }
<span class="lineNum">     261 </span>                :            : #endif
<span class="lineNum">     262 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptor-&gt;reqevents &amp; APR_POLLIN) {</span>
<span class="lineNum">     263 </span>                :<span class="lineNoCov">          0 :         FD_SET(fd, &amp;(pollset-&gt;p-&gt;readset));</span>
<span class="lineNum">     264 </span>                :            :     }
<span class="lineNum">     265 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptor-&gt;reqevents &amp; APR_POLLOUT) {</span>
<span class="lineNum">     266 </span>                :<span class="lineNoCov">          0 :         FD_SET(fd, &amp;(pollset-&gt;p-&gt;writeset));</span>
<span class="lineNum">     267 </span>                :            :     }
<span class="lineNum">     268 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptor-&gt;reqevents &amp;</span>
<span class="lineNum">     269 </span>                :            :         (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) {
<span class="lineNum">     270 </span>                :<span class="lineNoCov">          0 :         FD_SET(fd, &amp;(pollset-&gt;p-&gt;exceptset));</span>
<span class="lineNum">     271 </span>                :            :     }
<span class="lineNum">     272 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if ((int) fd &gt; pollset-&gt;p-&gt;maxfd) {</span>
<span class="lineNum">     273 </span>                :<span class="lineNoCov">          0 :         pollset-&gt;p-&gt;maxfd = (int) fd;</span>
<span class="lineNum">     274 </span>                :            :     }
<span class="lineNum">     275 </span>                :<span class="lineNoCov">          0 :     pollset-&gt;nelts++;</span>
<span class="lineNum">     276 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">     277 </span>                :            : }
<span class="lineNum">     278 </span>                :            : 
<a name="279"><span class="lineNum">     279 </span>                :            : static apr_status_t impl_pollset_remove(apr_pollset_t * pollset,</a>
<span class="lineNum">     280 </span>                :            :                                         const apr_pollfd_t * descriptor)
<span class="lineNum">     281 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     282 </span>                :            :     apr_uint32_t i;
<span class="lineNum">     283 </span>                :            :     apr_os_sock_t fd;
<span class="lineNum">     284 </span>                :            : 
<span class="lineNum">     285 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptor-&gt;desc_type == APR_POLL_SOCKET) {</span>
<span class="lineNum">     286 </span>                :<span class="lineNoCov">          0 :         fd = descriptor-&gt;desc.s-&gt;socketdes;</span>
<span class="lineNum">     287 </span>                :            :     }
<span class="lineNum">     288 </span>                :            :     else {
<span class="lineNum">     289 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">     290 </span>                :            :         return APR_EBADF;
<span class="lineNum">     291 </span>                :            : #else
<span class="lineNum">     292 </span>                :<span class="lineNoCov">          0 :         fd = descriptor-&gt;desc.f-&gt;filedes;</span>
<span class="lineNum">     293 </span>                :            : #endif
<span class="lineNum">     294 </span>                :            :     }
<span class="lineNum">     295 </span>                :            : 
<span class="lineNum">     296 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     for (i = 0; i &lt; pollset-&gt;nelts; i++) {</span>
<span class="lineNum">     297 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (descriptor-&gt;desc.s == pollset-&gt;p-&gt;query_set[i].desc.s) {</span>
<span class="lineNum">     298 </span>                :            :             /* Found an instance of the fd: remove this and any other copies */
<span class="lineNum">     299 </span>                :<span class="lineNoCov">          0 :             apr_uint32_t dst = i;</span>
<span class="lineNum">     300 </span>                :<span class="lineNoCov">          0 :             apr_uint32_t old_nelts = pollset-&gt;nelts;</span>
<span class="lineNum">     301 </span>                :<span class="lineNoCov">          0 :             pollset-&gt;nelts--;</span>
<span class="lineNum">     302 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             for (i++; i &lt; old_nelts; i++) {</span>
<span class="lineNum">     303 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (descriptor-&gt;desc.s == pollset-&gt;p-&gt;query_set[i].desc.s) {</span>
<span class="lineNum">     304 </span>                :<span class="lineNoCov">          0 :                     pollset-&gt;nelts--;</span>
<span class="lineNum">     305 </span>                :            :                 }
<span class="lineNum">     306 </span>                :            :                 else {
<span class="lineNum">     307 </span>                :<span class="lineNoCov">          0 :                     pollset-&gt;p-&gt;query_set[dst] = pollset-&gt;p-&gt;query_set[i];</span>
<span class="lineNum">     308 </span>                :<span class="lineNoCov">          0 :                     dst++;</span>
<span class="lineNum">     309 </span>                :            :                 }
<span class="lineNum">     310 </span>                :            :             }
<span class="lineNum">     311 </span>                :<span class="lineNoCov">          0 :             FD_CLR(fd, &amp;(pollset-&gt;p-&gt;readset));</span>
<span class="lineNum">     312 </span>                :<span class="lineNoCov">          0 :             FD_CLR(fd, &amp;(pollset-&gt;p-&gt;writeset));</span>
<span class="lineNum">     313 </span>                :<span class="lineNoCov">          0 :             FD_CLR(fd, &amp;(pollset-&gt;p-&gt;exceptset));</span>
<span class="lineNum">     314 </span>[<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (((int) fd == pollset-&gt;p-&gt;maxfd) &amp;&amp; (pollset-&gt;p-&gt;maxfd &gt; 0)) {</span>
<span class="lineNum">     315 </span>                :<span class="lineNoCov">          0 :                 pollset-&gt;p-&gt;maxfd--;</span>
<span class="lineNum">     316 </span>                :            :             }
<span class="lineNum">     317 </span>                :<span class="lineNoCov">          0 :             return APR_SUCCESS;</span>
<span class="lineNum">     318 </span>                :            :         }
<span class="lineNum">     319 </span>                :            :     }
<span class="lineNum">     320 </span>                :            : 
<span class="lineNum">     321 </span>                :<span class="lineNoCov">          0 :     return APR_NOTFOUND;</span>
<span class="lineNum">     322 </span>                :            : }
<span class="lineNum">     323 </span>                :            : 
<span class="lineNum">     324 </span>                :            : static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
<span class="lineNum">     325 </span>                :            :                                       apr_interval_time_t timeout,
<a name="326"><span class="lineNum">     326 </span>                :            :                                       apr_int32_t *num,</a>
<span class="lineNum">     327 </span>                :            :                                       const apr_pollfd_t **descriptors)
<span class="lineNum">     328 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     329 </span>                :            :     int rs;
<span class="lineNum">     330 </span>                :            :     apr_uint32_t i, j;
<span class="lineNum">     331 </span>                :            :     struct timeval tv, *tvptr;
<span class="lineNum">     332 </span>                :            :     fd_set readset, writeset, exceptset;
<span class="lineNum">     333 </span>                :<span class="lineNoCov">          0 :     apr_status_t rv = APR_SUCCESS;</span>
<span class="lineNum">     334 </span>                :            : 
<span class="lineNum">     335 </span>                :            : #ifdef WIN32
<span class="lineNum">     336 </span>                :            :     /* On Win32, select() must be presented with at least one socket to
<span class="lineNum">     337 </span>                :            :      * poll on, or select() will return WSAEINVAL.  So, we'll just
<span class="lineNum">     338 </span>                :            :      * short-circuit and bail now.
<span class="lineNum">     339 </span>                :            :      */
<span class="lineNum">     340 </span>                :            :     if (pollset-&gt;nelts == 0) {
<span class="lineNum">     341 </span>                :            :         (*num) = 0;
<span class="lineNum">     342 </span>                :            :         return APR_SUCCESS;
<span class="lineNum">     343 </span>                :            :     }
<span class="lineNum">     344 </span>                :            : #endif
<span class="lineNum">     345 </span>                :            : 
<span class="lineNum">     346 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (timeout &lt; 0) {</span>
<span class="lineNum">     347 </span>                :<span class="lineNoCov">          0 :         tvptr = NULL;</span>
<span class="lineNum">     348 </span>                :            :     }
<span class="lineNum">     349 </span>                :            :     else {
<span class="lineNum">     350 </span>                :<span class="lineNoCov">          0 :         tv.tv_sec = (long) apr_time_sec(timeout);</span>
<span class="lineNum">     351 </span>                :<span class="lineNoCov">          0 :         tv.tv_usec = (long) apr_time_usec(timeout);</span>
<span class="lineNum">     352 </span>                :<span class="lineNoCov">          0 :         tvptr = &amp;tv;</span>
<span class="lineNum">     353 </span>                :            :     }
<span class="lineNum">     354 </span>                :            : 
<span class="lineNum">     355 </span>                :<span class="lineNoCov">          0 :     memcpy(&amp;readset, &amp;(pollset-&gt;p-&gt;readset), sizeof(fd_set));</span>
<span class="lineNum">     356 </span>                :<span class="lineNoCov">          0 :     memcpy(&amp;writeset, &amp;(pollset-&gt;p-&gt;writeset), sizeof(fd_set));</span>
<span class="lineNum">     357 </span>                :<span class="lineNoCov">          0 :     memcpy(&amp;exceptset, &amp;(pollset-&gt;p-&gt;exceptset), sizeof(fd_set));</span>
<span class="lineNum">     358 </span>                :            : 
<span class="lineNum">     359 </span>                :            : #ifdef NETWARE
<span class="lineNum">     360 </span>                :            :     if (HAS_PIPES(pollset-&gt;p-&gt;set_type)) {
<span class="lineNum">     361 </span>                :            :         rs = pipe_select(pollset-&gt;p-&gt;maxfd + 1, &amp;readset, &amp;writeset, &amp;exceptset,
<span class="lineNum">     362 </span>                :            :                          tvptr);
<span class="lineNum">     363 </span>                :            :     }
<span class="lineNum">     364 </span>                :            :     else
<span class="lineNum">     365 </span>                :            : #endif
<span class="lineNum">     366 </span>                :<span class="lineNoCov">          0 :         rs = select(pollset-&gt;p-&gt;maxfd + 1, &amp;readset, &amp;writeset, &amp;exceptset,</span>
<span class="lineNum">     367 </span>                :            :                     tvptr);
<span class="lineNum">     368 </span>                :            : 
<span class="lineNum">     369 </span>                :<span class="lineNoCov">          0 :     (*num) = rs;</span>
<span class="lineNum">     370 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (rs &lt; 0) {</span>
<span class="lineNum">     371 </span>                :<span class="lineNoCov">          0 :         return apr_get_netos_error();</span>
<span class="lineNum">     372 </span>                :            :     }
<span class="lineNum">     373 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (rs == 0) {</span>
<span class="lineNum">     374 </span>                :<span class="lineNoCov">          0 :         return APR_TIMEUP;</span>
<span class="lineNum">     375 </span>                :            :     }
<span class="lineNum">     376 </span>                :<span class="lineNoCov">          0 :     j = 0;</span>
<span class="lineNum">     377 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     for (i = 0; i &lt; pollset-&gt;nelts; i++) {</span>
<span class="lineNum">     378 </span>                :            :         apr_os_sock_t fd;
<span class="lineNum">     379 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (pollset-&gt;p-&gt;query_set[i].desc_type == APR_POLL_SOCKET) {</span>
<span class="lineNum">     380 </span>                :<span class="lineNoCov">          0 :             fd = pollset-&gt;p-&gt;query_set[i].desc.s-&gt;socketdes;</span>
<span class="lineNum">     381 </span>                :            :         }
<span class="lineNum">     382 </span>                :            :         else {
<span class="lineNum">     383 </span>[<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if ((pollset-&gt;flags &amp; APR_POLLSET_WAKEABLE) &amp;&amp;</span>
<span class="lineNum">     384 </span>                :            :                 pollset-&gt;p-&gt;query_set[i].desc.f == pollset-&gt;wakeup_pipe[0]) {
<span class="lineNum">     385 </span>                :<span class="lineNoCov">          0 :                 apr_pollset_drain_wakeup_pipe(pollset);</span>
<span class="lineNum">     386 </span>                :<span class="lineNoCov">          0 :                 rv = APR_EINTR;</span>
<span class="lineNum">     387 </span>                :<span class="lineNoCov">          0 :                 continue;</span>
<span class="lineNum">     388 </span>                :            :             }
<span class="lineNum">     389 </span>                :            :             else {
<span class="lineNum">     390 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">     391 </span>                :            :                 return APR_EBADF;
<span class="lineNum">     392 </span>                :            : #else
<span class="lineNum">     393 </span>                :<span class="lineNoCov">          0 :                 fd = pollset-&gt;p-&gt;query_set[i].desc.f-&gt;filedes;</span>
<span class="lineNum">     394 </span>                :            : #endif
<span class="lineNum">     395 </span>                :            :             }
<span class="lineNum">     396 </span>                :            :         }
<span class="lineNum">     397 </span>[<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (FD_ISSET(fd, &amp;readset) || FD_ISSET(fd, &amp;writeset) ||</span>
<span class="lineNum">         </span>        [<span class="branchNoExec" title="Branch 4 was not executed"> # </span><span class="branchNoExec" title="Branch 5 was not executed"> # </span>]
<span class="lineNum">     398 </span>                :            :             FD_ISSET(fd, &amp;exceptset)) {
<span class="lineNum">     399 </span>                :<span class="lineNoCov">          0 :             pollset-&gt;p-&gt;result_set[j] = pollset-&gt;p-&gt;query_set[i];</span>
<span class="lineNum">     400 </span>                :<span class="lineNoCov">          0 :             pollset-&gt;p-&gt;result_set[j].rtnevents = 0;</span>
<span class="lineNum">     401 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (FD_ISSET(fd, &amp;readset)) {</span>
<span class="lineNum">     402 </span>                :<span class="lineNoCov">          0 :                 pollset-&gt;p-&gt;result_set[j].rtnevents |= APR_POLLIN;</span>
<span class="lineNum">     403 </span>                :            :             }
<span class="lineNum">     404 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (FD_ISSET(fd, &amp;writeset)) {</span>
<span class="lineNum">     405 </span>                :<span class="lineNoCov">          0 :                 pollset-&gt;p-&gt;result_set[j].rtnevents |= APR_POLLOUT;</span>
<span class="lineNum">     406 </span>                :            :             }
<span class="lineNum">     407 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (FD_ISSET(fd, &amp;exceptset)) {</span>
<span class="lineNum">     408 </span>                :<span class="lineNoCov">          0 :                 pollset-&gt;p-&gt;result_set[j].rtnevents |= APR_POLLERR;</span>
<span class="lineNum">     409 </span>                :            :             }
<span class="lineNum">     410 </span>                :<span class="lineNoCov">          0 :             j++;</span>
<span class="lineNum">     411 </span>                :            :         }
<span class="lineNum">     412 </span>                :            :     }
<span class="lineNum">     413 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (((*num) = j) != 0)</span>
<span class="lineNum">     414 </span>                :<span class="lineNoCov">          0 :         rv = APR_SUCCESS;</span>
<span class="lineNum">     415 </span>                :            : 
<span class="lineNum">     416 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (descriptors)</span>
<span class="lineNum">     417 </span>                :<span class="lineNoCov">          0 :         *descriptors = pollset-&gt;p-&gt;result_set;</span>
<span class="lineNum">     418 </span>                :<span class="lineNoCov">          0 :     return rv;</span>
<span class="lineNum">     419 </span>                :            : }
<span class="lineNum">     420 </span>                :            : 
<span class="lineNum">     421 </span>                :            : static apr_pollset_provider_t impl = {
<span class="lineNum">     422 </span>                :            :     impl_pollset_create,
<span class="lineNum">     423 </span>                :            :     impl_pollset_add,
<span class="lineNum">     424 </span>                :            :     impl_pollset_remove,
<span class="lineNum">     425 </span>                :            :     impl_pollset_poll,
<span class="lineNum">     426 </span>                :            :     NULL,
<span class="lineNum">     427 </span>                :            :     &quot;select&quot;
<span class="lineNum">     428 </span>                :            : };
<span class="lineNum">     429 </span>                :            : 
<span class="lineNum">     430 </span>                :            : apr_pollset_provider_t *apr_pollset_provider_select = &amp;impl;
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
